/*--------------------------------*- C++ -*----------------------------------*\
  =========                 |
  \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
   \\    /   O peration     | Website:  https://openfoam.org
    \\  /    A nd           | Version:  7
     \\/     M anipulation  |
\*---------------------------------------------------------------------------*/
FoamFile
{
    version     2.0;
    format      ascii;
    class       dictionary;
    location    "system";
    object      controlDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

application     icoFoam;

startFrom       startTime;

startTime       0;

stopAt          endTime;

endTime         0.5;

deltaT          0.005;

writeControl    timeStep;

writeInterval   20;

purgeWrite      0;

writeFormat     ascii;

writePrecision  6;

writeCompression off;

timeFormat      general;

timePrecision   6;

runTimeModifiable true;

functions
{
	extraInfo
	{
	type 		 coded;
	functionObjectLibs   ("libutilityFunctionObjects.so");
	name		dummy;
	
	codeExecute
	#{

	const volVectorField& U = mesh().lookupObject<volVectorField>("U");
	Info<<"max U=" <<max(mag(U)).value() << nl;
	const volScalarField& p = mesh().lookupObject<volScalarField>("p");
	Info<< "min/max p=" <<min(p).value()<< "," <<max(p).value()<< nl;
	if(max(mag(U)).value()>10)
	{
	Info<<"wokao"<<endl;
	}

label wallsID = mesh().boundaryMesh().findPatchID("walls");
Info<<"wallsID = "<< wallsID<<endl;
label inletID = mesh().boundaryMesh().findPatchID("inlet");
Info<<"inletID = "<< inletID<<endl;

/*
	forAll(U,faceI)
	{
	scalar x = U[faceI].x();
Info<<"U=  /" <<x << nl;

	forAll(U,cellI)
	{
	scalar k = U[cellI].x();
Info<<"ZSLX  " <<k-x ;
 	
	}

	scalar y = U[faceI].y();	
	}
Info<<"Mesh().cells()[0] == "<<mesh().cells()[123]<<endl ;
*/	


	#};


/*
	codeWrite //maybe wrong just test
	#{
	const volScalarField& p = mesh().lookupObject<volScalarField>("p");
	IOList<scalar> testTT
            (
                IOobject
                (
                    "testTT",
                    mesh().time().constant(),
                    "../postProcessing",
                    mesh(),
                    IOobject::NO_READ,
                    IOobject::AUTO_WRITE
                ),
                1
            );
            testTT = p.weightedAverage(mesh().V()).value();


	#};	
*/




	}

	minmaxdomain
	{
	type fieldMinMax;
	functionObjectLibs ("libfieldFuctionObjects.so");
	enabled true;
	mode component;
	writeControl writeTime;
	//writeInternal 1;
	log true;
	fields (p U);
	}



}



// ************************************************************************* //
